
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cinemasystem.app.factory;

import com.cinemasystem.app.modules.allscheduling_given.CalculateMovieDuration;
import com.cinemasystem.app.modules.allscheduling_given.Impl.CalculateMovieDurationImpl;
import com.cinemasystem.app.modules.allscheduling_given.Impl.ProvideMovieServiceImpl;
import com.cinemasystem.app.modules.allscheduling_given.ProvideMovieService;
import com.cinemasystem.model.CinemaRoom;
import com.cinemasystem.model.Movie;
import com.cinemasystem.model.MovieGenre;
import com.cinemasystem.model.MovieTechnology;
import com.cinemasystem.model.Person;
import com.cinemasystem.model.Price;
import com.cinemasystem.model.SeatSession;
import com.cinemasystem.model.Users;
import com.cinemasystem.app.modules.bookmovie_lucky.CinemaRoomService;
import com.cinemasystem.app.modules.bookmovie_lucky.Impl.CinemaRoomServiceImpl;
import com.cinemasystem.app.modules.movieservice_nomaphelo.Impl.MovieGenreServiceImpl;
import com.cinemasystem.app.modules.makepayment_avela.Impl.MovieTechnologyPriceServiceImpl;
import com.cinemasystem.app.modules.movieservice_nomaphelo.MovieGenreService;
import com.cinemasystem.app.modules.makepayment_avela.MovieTechnologyPriceService;
import com.cinemasystem.model.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 *
 * @Avela
 */
/*public class AppFactory {
    
    public static MovieTechnology movieTechnologyModel() {
        return new MovieTechnology();
    }
    
    public static MovieTechnology createMovieTechnology(Map<String, String> values) {
        MovieTechnology movieTechnology = new MovieTechnology();
        
        values.put("status", "New Movie");
        values.put("price", "30");
        values.put("tech", "3D A");
        movieTechnology.setMovieTechnology(values.get("tech"));
        Price price = new Price();        
        price.setPrice(Double.parseDouble(values.get("price")));
        movieTechnology.setPrice(price);
        movieTechnology.setStatus(values.get("status"));
        return movieTechnology;
    }
}*/

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @Avela
 */
public class AppFactory {
    public static MovieTechnology movieTechnologyModel() {
        return new MovieTechnology();
    }

    public static MovieTechnology createMovieTechnology(Map<String, String> values) {
        MovieTechnology movieTechnology = new MovieTechnology();

        movieTechnology.setMovieTechnology(values.get("tech"));
        Price price = new Price();
        price.setPrice(new Double(values.get("price")));
        movieTechnology.setPrice(price);
        movieTechnology.setStatus(values.get("status"));
        return movieTechnology;
    }

    public static MovieGenre getMovieGenreInstance() {        
        return new MovieGenre();
    }   
    
    public static List<Movie> getMovie() {
        return new ArrayList<Movie>();
    }

    public static MovieTechnologyPriceService getMovieTechnologyPriceServiceInstance() {
        return new MovieTechnologyPriceServiceImpl();
    }

    public static MovieGenre getMovieGenreWithMovie(Map<String, String> values, MovieTechnology movieTechnology) {
        
        Movie movie = new Movie();
        movie.setMovieName(values.get("movieName"));
        movie.setDatePublished(new Date());
        movie.setDescription(values.get("description"));
        movie.setMovieDuration(new Long(values.get("movieDuration")));
        movie.setNameOfdistributor(values.get("nameOfdistributor"));
        movie.setMovieTechnology(movieTechnology);
        List<Movie> movies = new ArrayList<Movie>();
        
        MovieGenreService movieGenreService = new MovieGenreServiceImpl();
        MovieGenre movieGenre = movieGenreService.getGenre(values.get("movieGenre"));
        //movie.setMovieGenre(movieGenre);
        movies.add(movie);
        movieGenre.setMovie(movies);
        
        return movieGenre;
    }
    
    public static CinemaRoom createCinema(Map<String, String> values) {
        CinemaRoom cinemaRoom = new CinemaRoom();
        
        cinemaRoom.setCinemaName(values.get("cinemaname1"));
        
        return cinemaRoom;
    }

    public static CinemaRoom createCinemaRoomSeatSession(Map<String, String> values) {
        
        CinemaRoomService cinemaRoomService = new CinemaRoomServiceImpl();
        CinemaRoom cinemaRoom = cinemaRoomService.getCinemaRoom(values.get("cinemaname"));
        SeatSession seatSession = new SeatSession();
        List<SeatSession> seatSessions = new ArrayList<SeatSession>();
        seatSession.setSeatNumber(new Long(values.get("seatNumber")));
        seatSession.setMorningSession(values.get("morningSession"));
        seatSession.setAfterSession(values.get("afterSession"));
        seatSession.setEveningSession(values.get("eveningSession"));
        seatSession.setSessionDate(new Date());
        
        seatSessions.add(seatSession);
        
        cinemaRoom.setSeatSessions(seatSessions);
        
        return cinemaRoom;
    }
    public static Users getUserCredencials(Map<String, String> values) {
        Users user = new Users();
        Person person = new Person();
        person.setFirstName(values.get("lastName"));
        person.setLastName(values.get("firstName"));
        user.setPerson(person);
        user.setUserName(values.get("userName"));
        user.setPassword(values.get("password"));
        
        return user;
    }

    public static MovieScheduler getMovieSchedulerObject(Map<String, String> values) {
        MovieScheduler movieScheduler = new MovieScheduler();
        
        CinemaRoomService cinemaRoomService = new CinemaRoomServiceImpl();
        CinemaRoom cinemaRoom = cinemaRoomService.getCinemaRoom(values.get("cinemaName"));
        movieScheduler.setCinemaRoom(cinemaRoom);

        ProvideMovieService provideMovieService = new ProvideMovieServiceImpl();
        Movie movie = provideMovieService.getMovie(values.get("movieName"), values.get("movieGenre"));
        
        movieScheduler.setMovie(movie);
        CalculateMovieDuration calculateMovieDuration = new CalculateMovieDurationImpl();
        String endTime = calculateMovieDuration.getMovieDuration(movie.getMovieDuration().toString(), values.get("startTime"));
        movieScheduler.setStartTime(values.get("startTime"));
        movieScheduler.setEndTime(endTime);
        
        return movieScheduler;
    }
}
